<?php
include "../../fun.php";
isLogin();
$db=conndb();
$yourName=$_POST["yourName"];
$tel=$_POST["tel"];
$QQ=$_POST["QQ"];
$email=$_POST["email"];
$title=$_POST["title"];
$content=$_POST["content"];
$time=time();
if ($yourName==='') {
    $data=["code"=>1,"msg"=>"姓名不能为空","yourName"=>$yourName];
}else if ($tel==='') {
    $data=["code"=>1,"msg"=>"电话不能为空","tel"=>$tel];
}
if($yourName!==''&&$tel!==''){
    $sql="insert into message (username,phone,qq,email,title,content,time) values ('{$yourName}','{$tel}','{$QQ}','{$email}','{$title}','{$content}','{$time}')";
    $db->exec($sql);
    $data=["code"=>0,"msg"=>"留言成功"];
}
echo json_encode($data,JSON_UNESCAPED_UNICODE);
?>